#!/usr/bin/env python
# encoding: utf-8
# @author: liusir
# @file: unittest_test_api_case.py
# @time: 2022/11/16 8:49 PM

import unittest
import paramunittest
from utlis.testcase_data_utils import TestcaseDataUtils
from utlis.requests_utils import RequestsUtils
from utlis.log_utils import logger

test_case_lists = TestcaseDataUtils().convert_testcase_data_to_list_unittest()

@paramunittest.parametrized(
    *test_case_lists
)
class TestApiCase(paramunittest.ParametrizedTestCase):
    def setParameters(self, case_id, case_step):
        self.case_id = case_id
        self.case_step = case_step
    def test_api_case(self):
        logger.info('测试用例[%s]开始执行'%self.case_step[0].get('测试用例编号'))
        self._testMethodName = self.case_step[0].get('测试用例编号')
        self._testMethodDoc = self.case_step[0].get('测试用例名称')
        actual_result = RequestsUtils().request_by_step(self.case_step)
        logger.info('测试用例[%s]执行结束' % self.case_step[0].get('测试用例编号'))
        self.assertTrue( actual_result['check_result'],actual_result['message'] )

if __name__=="__main__":
    unittest.main()